#!/bin/bash
#
# Copyright (c) Citrix Systems 2008. All rights reserved.
#
#    ./plot-result vm_per_host host1 ... hostN
#

if [ $# -le 1 ]; then 
   echo "Usage: $0 vm_per_host host1 [host2 ... hostN]"
   echo "${0} plot the result of ./stress-tests. Need to have all the resulting .dat files of the test in the current directory. Results are .ps files."
   exit 1
fi 

VM_PER_HOST=$1

shift
HOSTS=$@
MASTER=$1

for OP in "start-shutdown" "suspend-resume" "reboot" "live-migrate" "non-live-migrate"; do
    STR=""
    for HOST in $HOSTS; do
	for i in `seq 1 ${VM_PER_HOST}`; do
	    if [ "${STR}" == "" ]
	    then
		STR="'debian-etch-${HOST}-${i}.${OP}.dat' title '${HOST}-${i}' with lines"
	    else
		STR+=", 'debian-etch-${HOST}-${i}.${OP}.dat' title '${HOST}-${i}' with lines"
	    fi
	done
    done
    echo "set terminal postscript color eps" > tmp.conf
    echo "set output '${OP}.ps'" >> tmp.conf
    echo "plot ${STR}" >> tmp.conf
    gnuplot tmp.conf
done


